home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / zcolor1.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  6.0 KB  |  219 lines

  1. /* Copyright (C) 1993, 2000 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: zcolor1.c,v 1.3 2000/09/19 19:00:53 lpd Exp $ */
  20. /* Level 1 extended color operators */
  21. #include "ghost.h"
  22. #include "oper.h"
  23. #include "estack.h"
  24. #include "ialloc.h"
  25. #include "igstate.h"
  26. #include "iutil.h"
  27. #include "store.h"
  28. #include "gxfixed.h"
  29. #include "gxmatrix.h"
  30. #include "gzstate.h"
  31. #include "gxdevice.h"
  32. #include "gxcmap.h"
  33. #include "gscolor1.h"
  34. #include "gscssub.h"
  35. #include "gxcspace.h"
  36. #include "icolor.h"
  37. #include "iimage.h"
  38.  
  39. /* - currentblackgeneration <proc> */
  40. private int
  41. zcurrentblackgeneration(i_ctx_t *i_ctx_p)
  42. {
  43.     os_ptr op = osp;
  44.  
  45.     push(1);
  46.     *op = istate->black_generation;
  47.     return 0;
  48. }
  49.  
  50. /* - currentcmykcolor <cyan> <magenta> <yellow> <black> */
  51. private int
  52. zcurrentcmykcolor(i_ctx_t *i_ctx_p)
  53. {
  54.     os_ptr op = osp;
  55.     float par[4];
  56.     int code = gs_currentcmykcolor(igs, par);
  57.  
  58.     if (code < 0)
  59.     return code;
  60.     push(4);
  61.     make_floats(op - 3, par, 4);
  62.     return 0;
  63. }
  64.  
  65. /* - currentcolortransfer <redproc> <greenproc> <blueproc> <grayproc> */
  66. private int
  67. zcurrentcolortransfer(i_ctx_t *i_ctx_p)
  68. {
  69.     os_ptr op = osp;
  70.  
  71.     push(4);
  72.     op[-3] = istate->transfer_procs.colored.red;
  73.     op[-2] = istate->transfer_procs.colored.green;
  74.     op[-1] = istate->transfer_procs.colored.blue;
  75.     *op = istate->transfer_procs.colored.gray;
  76.     return 0;
  77. }
  78.  
  79. /* - currentundercolorremoval <proc> */
  80. private int
  81. zcurrentundercolorremoval(i_ctx_t *i_ctx_p)
  82. {
  83.     os_ptr op = osp;
  84.  
  85.     push(1);
  86.     *op = istate->undercolor_removal;
  87.     return 0;
  88. }
  89.  
  90. /* <proc> setblackgeneration - */
  91. private int
  92. zsetblackgeneration(i_ctx_t *i_ctx_p)
  93. {
  94.     os_ptr op = osp;
  95.     int code;
  96.  
  97.     check_proc(*op);
  98.     check_ostack(zcolor_remap_one_ostack - 1);
  99.     check_estack(1 + zcolor_remap_one_estack);
  100.     code = gs_setblackgeneration_remap(igs, gs_mapped_transfer, false);
  101.     if (code < 0)
  102.     return code;
  103.     istate->black_generation = *op;
  104.     pop(1);
  105.     push_op_estack(zcolor_remap_color);
  106.     return zcolor_remap_one(i_ctx_p, &istate->black_generation,
  107.                 igs->black_generation, igs,
  108.                 zcolor_remap_one_finish);
  109. }
  110.  
  111. /* <cyan> <magenta> <yellow> <black> setcmykcolor - */
  112. private int
  113. zsetcmykcolor(i_ctx_t *i_ctx_p)
  114. {
  115.     os_ptr op = osp;
  116.     double par[4];
  117.     int code;
  118.  
  119.     if ((code = num_params(op, 4, par)) < 0 ||
  120.     (code = gs_setcmykcolor(igs, par[0], par[1], par[2], par[3])) < 0
  121.     )
  122.     return code;
  123.     make_null(&istate->colorspace.array);
  124.     pop(4);
  125.     return 0;
  126. }
  127.  
  128. /* <redproc> <greenproc> <blueproc> <grayproc> setcolortransfer - */
  129. private int
  130. zsetcolortransfer(i_ctx_t *i_ctx_p)
  131. {
  132.     os_ptr op = osp;
  133.     int code;
  134.  
  135.     check_proc(op[-3]);
  136.     check_proc(op[-2]);
  137.     check_proc(op[-1]);
  138.     check_proc(*op);
  139.     check_ostack(zcolor_remap_one_ostack * 4 - 4);
  140.     check_estack(1 + zcolor_remap_one_estack * 4);
  141.     istate->transfer_procs.colored.red = op[-3];
  142.     istate->transfer_procs.colored.green = op[-2];
  143.     istate->transfer_procs.colored.blue = op[-1];
  144.     istate->transfer_procs.colored.gray = *op;
  145.     if ((code = gs_setcolortransfer_remap(igs,
  146.                      gs_mapped_transfer, gs_mapped_transfer,
  147.                      gs_mapped_transfer, gs_mapped_transfer,
  148.                       false)) < 0
  149.     )
  150.     return code;
  151.     /* Use osp rather than op here, because zcolor_remap_one pushes. */
  152.     pop(4);
  153.     push_op_estack(zcolor_reset_transfer);
  154.     if ((code = zcolor_remap_one(i_ctx_p,
  155.                  &istate->transfer_procs.colored.red,
  156.                  igs->set_transfer.colored.red, igs,
  157.                  zcolor_remap_one_finish)) < 0 ||
  158.     (code = zcolor_remap_one(i_ctx_p,
  159.                  &istate->transfer_procs.colored.green,
  160.                  igs->set_transfer.colored.green, igs,
  161.                  zcolor_remap_one_finish)) < 0 ||
  162.     (code = zcolor_remap_one(i_ctx_p,
  163.                  &istate->transfer_procs.colored.blue,
  164.                  igs->set_transfer.colored.blue, igs,
  165.                  zcolor_remap_one_finish)) < 0 ||
  166.     (code = zcolor_remap_one(i_ctx_p, &istate->transfer_procs.colored.gray,
  167.                  igs->set_transfer.colored.gray, igs,
  168.                  zcolor_remap_one_finish)) < 0
  169.     )
  170.     return code;
  171.     return o_push_estack;
  172. }
  173.  
  174. /* <proc> setundercolorremoval - */
  175. private int
  176. zsetundercolorremoval(i_ctx_t *i_ctx_p)
  177. {
  178.     os_ptr op = osp;
  179.     int code;
  180.  
  181.     check_proc(*op);
  182.     check_ostack(zcolor_remap_one_ostack - 1);
  183.     check_estack(1 + zcolor_remap_one_estack);
  184.     code = gs_setundercolorremoval_remap(igs, gs_mapped_transfer, false);
  185.     if (code < 0)
  186.     return code;
  187.     istate->undercolor_removal = *op;
  188.     pop(1);
  189.     push_op_estack(zcolor_remap_color);
  190.     return zcolor_remap_one(i_ctx_p, &istate->undercolor_removal,
  191.                 igs->undercolor_removal, igs,
  192.                 zcolor_remap_one_signed_finish);
  193. }
  194.  
  195. /* <width> <height> <bits/comp> <matrix> */
  196. /*      <datasrc_0> ... <datasrc_ncomp-1> true <ncomp> colorimage - */
  197. /*      <datasrc> false <ncomp> colorimage - */
  198. private int
  199. zcolorimage(i_ctx_t *i_ctx_p)
  200. {
  201.     return zimage_multiple(i_ctx_p, false);
  202. }
  203.  
  204. /* ------ Initialization procedure ------ */
  205.  
  206. const op_def zcolor1_op_defs[] =
  207. {
  208.     {"0currentblackgeneration", zcurrentblackgeneration},
  209.     {"0currentcmykcolor", zcurrentcmykcolor},
  210.     {"0currentcolortransfer", zcurrentcolortransfer},
  211.     {"0currentundercolorremoval", zcurrentundercolorremoval},
  212.     {"1setblackgeneration", zsetblackgeneration},
  213.     {"4setcmykcolor", zsetcmykcolor},
  214.     {"4setcolortransfer", zsetcolortransfer},
  215.     {"1setundercolorremoval", zsetundercolorremoval},
  216.     {"7colorimage", zcolorimage},
  217.     op_def_end(0)
  218. };
  219.